package cn.z2huo.demo.mapstruct.convert.user;

import cn.z2huo.core.util.object.BeanUtils;
import cn.z2huo.demo.mapstruct.dataobject.UserDO;
import cn.z2huo.demo.mapstruct.dataobject.UserRoleRelationDO;
import cn.z2huo.demo.mapstruct.vo.UserRoleRelationVO;
import cn.z2huo.demo.mapstruct.vo.UserVO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;

import java.util.List;

/**
 * <p>
 *
 * @author z2huo
 */
@Mapper
public interface UserConvert {

    UserConvert INSTANCE = Mappers.getMapper(UserConvert.class);

    UserVO convert(UserDO userDO);

    default UserVO convert(UserDO userDO, List<UserRoleRelationDO> userRoleRelationDOList) {
        UserVO userVO = BeanUtils.toBean(userDO, UserVO.class);
        userVO.setUserRoleRelationVOList(BeanUtils.copyToList(userRoleRelationDOList, UserRoleRelationVO.class));
        return userVO;
    }

}
